package com.example.demo.plc;

import com.github.s7connector.api.S7Connector;
import com.github.s7connector.api.factory.S7ConnectorFactory;
import com.github.s7connector.exception.S7Exception;

/**
 * 连接plc
 */
public class S7ConnectorPLC {
    /**
     * 初始话连接
     * @param ipAdress  plc地址
     * @return  返回连接
     * @throws S7Exception   抛出连接一场
     */
    public static S7Connector initConnect(String ipAdress) throws S7Exception {
        return S7ConnectorFactory.buildTCPConnector()
                .withHost(ipAdress)
                .withPort(102)
                .withRack(0)
                .withSlot(1)
                .withTimeout(3000)
                .build();
    }


}
